<html>
<head><meta charset="utf-8"><title>global executors · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html">global executors</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="180752458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180752458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180752458">(Nov 14 2019 at 17:23)</a>:</h4>
<p>Wrote this post today: <a href="https://boats.gitlab.io/blog/post/global-executors/" target="_blank" title="https://boats.gitlab.io/blog/post/global-executors/">https://boats.gitlab.io/blog/post/global-executors/</a></p>



<a name="180759031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759031">(Nov 14 2019 at 18:29)</a>:</h4>
<p>I bet you've already considered this already, but I wanted to make explicit that building this into std would make it impossible to have two (or more) global executors running in the same program, which, while undesirable, is possible today using the library-specific spawn functions</p>



<a name="180759231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759231">(Nov 14 2019 at 18:30)</a>:</h4>
<p>Note, though, that this could be avoided by using thread-local spawners rather than a single global (but that has its own complexity costs)</p>



<a name="180759255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759255">(Nov 14 2019 at 18:31)</a>:</h4>
<p>Yes. Well, its still possible using a different API from <code>std::task::spawn</code> of course</p>



<a name="180759647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759647">(Nov 14 2019 at 18:34)</a>:</h4>
<p><span class="user-mention" data-user-id="203289">@boats</span> Not if the two libraries both set <code>#[global_executor]</code> internally, which is my fear</p>



<a name="180759699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759699">(Nov 14 2019 at 18:35)</a>:</h4>
<p>but yes, that's a good point that we could potentially build best-practices that would help resolve that situation</p>



<a name="180759778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759778">(Nov 14 2019 at 18:36)</a>:</h4>
<p>I can imagine making everyone declare <code>#[global_executor]</code> in every program would be rather unpopular, though</p>



<a name="180759791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759791">(Nov 14 2019 at 18:36)</a>:</h4>
<p>I see what you mean. Yes, libraries shouldn't depend on crates that set <code>global_executor</code> either.</p>



<a name="180759851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759851">(Nov 14 2019 at 18:36)</a>:</h4>
<p>That's one reason to provide a simple default, so libraries can "work" in testing mode without them having to add some <code>dev-dependency</code> or something</p>



<a name="180759899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180759899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180759899">(Nov 14 2019 at 18:37)</a>:</h4>
<p>These sorts of global "only one person gets to set it" resources are a nightmare in many other language's ecosystems-- I once spent multiple weeks untangling JVM logging frameworks from various OSS libraries :)</p>



<a name="180760004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180760004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180760004">(Nov 14 2019 at 18:38)</a>:</h4>
<p>Agreed, which is why I think we should be very careful about how many we add, and I don't think we should make it possible for users to define their own.</p>



<a name="180773522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180773522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180773522">(Nov 14 2019 at 20:51)</a>:</h4>
<p>The "only one global allocator" approach has worked out reasonably well so far IMO. Crates like jemallocator don't set the global allocator themselves by default. That's left to the end user (maybe by turning on a Cargo feature or something like that).</p>



<a name="180774291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180774291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180774291">(Nov 14 2019 at 21:00)</a>:</h4>
<p>though it'll probably be much more common to set a global executor than global allocator</p>



<a name="180865079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/180865079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#180865079">(Nov 15 2019 at 19:42)</a>:</h4>
<p>much more common, I'd think</p>



<a name="182254297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182254297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Khionu Sybiern <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182254297">(Nov 30 2019 at 20:36)</a>:</h4>
<p>Hi, I'd like to help out to get Global Executors going in Rust. Is there anything that's ready to be picked up, designing or code?</p>



<a name="182474180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182474180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182474180">(Dec 03 2019 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="252217">@Khionu Sybiern</span> <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span> -- not really, I think there's still a lot of active debate if that is something we would actually want</p>



<a name="182499886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182499886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Khionu Sybiern <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182499886">(Dec 03 2019 at 21:44)</a>:</h4>
<p>What are the issues being debated? Is there another place this discussion is happening?</p>



<a name="182600818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182600818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182600818">(Dec 04 2019 at 21:20)</a>:</h4>
<p>I’d much rather have some sort of a task-local mechanism and then make executor one of those task local things</p>



<a name="182606015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182606015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Khionu Sybiern <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182606015">(Dec 04 2019 at 22:18)</a>:</h4>
<p>Task-local? Not sure what you mean. The Executor can't belong to a Task.</p>



<a name="182637664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182637664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182637664">(Dec 05 2019 at 08:22)</a>:</h4>
<p>The task normally only needs to have a handle to submit tasks to the executor, the executor itself can either be owned at a higher level or be reference counted via the handles</p>



<a name="182637724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182637724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182637724">(Dec 05 2019 at 08:23)</a>:</h4>
<p>There was significant discussion of the idea in this internals thread: <a href="https://internals.rust-lang.org/t/global-executors/11295" target="_blank" title="https://internals.rust-lang.org/t/global-executors/11295">https://internals.rust-lang.org/t/global-executors/11295</a></p>



<a name="182664511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/182664511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#182664511">(Dec 05 2019 at 14:38)</a>:</h4>
<p>What <span class="user-mention" data-user-id="210267">@Nemo157</span> said.</p>



<a name="183087021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/183087021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#183087021">(Dec 10 2019 at 18:25)</a>:</h4>
<p><span class="user-mention" data-user-id="252217">@Khionu Sybiern</span> one thing that's more short-term is the <code>thread::block_on</code> API, which is not such a huge addition as a global executor. There's an open PR, but I think it needs an RFC to work out some of the details.</p>



<a name="183087038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/global%20executors/near/183087038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/global.20executors.html#183087038">(Dec 10 2019 at 18:25)</a>:</h4>
<p>Happy to discuss these details with you if you'd be interested in writing an RFC for the API</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>